//
//  AccountManagerViewController.m
//  muscleLife
//
//  Created by xalo on 16/5/1.
//  Copyright © 2016年 HeavenAndHell. All rights reserved.
//

#import "AccountManagerViewController.h"

@interface AccountManagerViewController ()

@end

@implementation AccountManagerViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)exitLogin:(UIButton *)sender {

//    [AVUser logOut];
//    if (![AVUser currentUser]) {
//        [self.navigationController popToRootViewControllerAnimated:YES];
//    }
    [self showAlertViewController];
}

-(void)showAlertViewController{

    UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"确认登出？" preferredStyle:UIAlertControllerStyleAlert];

    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {

        [self.navigationController popViewControllerAnimated:YES];
    }];

    UIAlertAction *sureActon = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

        [AVUser logOut];
        if (![AVUser currentUser]) {
            [self.navigationController popToRootViewControllerAnimated:YES];
        }else{

            NSLog(@"登出失败");
        }
    }];
    [alert addAction:cancelAction];
    [alert addAction:sureActon];
    [self presentViewController:alert animated:YES completion:nil];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
